using System;
using System.Data;

using Wicresoft.Common;

namespace Wicresoft.Messages.Entity
{
    [Table("ReceiveStat", "ID", "Wicresoft.Messages.ConnectionString")]
    public class ReceiveStat : Info
    {
        #region SQL column name consts
        public const string SQLCOL_ID = "ID";
        public const string SQLCOL_USERNAME = "UserName";
        public const string SQLCOL_STATDATE = "StatDate";
        public const string SQLCOL_MODULEID = "ModuleID";
        public const string SQLCOL_DEVICEID = "DeviceID";
        public const string SQLCOL_TOTALCOUNT = "TotalCount";
        public const string SQLCOL_DEPARTMENTPATH = "DepartmentPath";
        #endregion


        #region Contructors
        /// <summary>
        /// Construct empty entity
        /// </summary>
        public ReceiveStat() { }

        /// <summary>
        /// Construct entity by primary key, other fields will be assigned by 
        /// "Load" method.
        /// </summary>
        public ReceiveStat(int ID)
        {
            this.ID = ID;
        }
        #endregion

        public override void Init(DataRow row)
        {
            ID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_ID]);
            UserName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_USERNAME]);
            StatDate = (DateTime)ObjectType.DateTimeTypeHelper.Read(row[SQLCOL_STATDATE]);
            ModuleID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_MODULEID]);
            DeviceID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_DEVICEID]);
            TotalCount = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_TOTALCOUNT]);
            DepartmentPath = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_DEPARTMENTPATH]);
        }

        #region Properties
        #region Property <int> ID
        [Property("ID", 4, SqlDbType.Int, true, true)]
        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }
        private int _ID = int.MinValue;
        #endregion

        #region Property <string> UserName
        [Property("UserName", 100, SqlDbType.NVarChar, false, false)]
        public string UserName
        {
            get { return _UserName; }
            set { _UserName = value; }
        }
        private string _UserName = null;
        #endregion

        #region Property <DateTime> StatDate
        [Property("StatDate", 16, SqlDbType.DateTime, false, false)]
        public DateTime StatDate
        {
            get { return _StatDate; }
            set { _StatDate = value; }
        }
        private DateTime _StatDate = DateTime.MinValue;
        #endregion

        #region Property <Guid> ModuleID
        [Property("ModuleID", 16, SqlDbType.UniqueIdentifier, false, false)]
        public Guid ModuleID
        {
            get { return _ModuleID; }
            set { _ModuleID = value; }
        }
        private Guid _ModuleID = Guid.Empty;
        #endregion

        #region Property <int> DeviceID
        [Property("DeviceID", 4, SqlDbType.Int, false, false)]
        public int DeviceID
        {
            get { return _DeviceID; }
            set { _DeviceID = value; }
        }
        private int _DeviceID = int.MinValue;
        #endregion

        #region Property <int> TotalCount
        [Property("TotalCount", 4, SqlDbType.Int, false, false)]
        public int TotalCount
        {
            get { return _TotalCount; }
            set { _TotalCount = value; }
        }
        private int _TotalCount = int.MinValue;
        #endregion

        #region Property <string> DepartmentPath
        [Property("DepartmentPath", 400, SqlDbType.NVarChar, false, false)]
        public string DepartmentPath
        {
            get { return _DepartmentPath; }
            set { _DepartmentPath = value; }
        }
        private string _DepartmentPath = null;
        #endregion
        #endregion


        public bool LoadByIdentity(int ID)
        {
            return DataAccess.SelectByIdentity(this, Convert.ToInt64(ID));
        }


        public bool DeleteByIdentity()
        {
            return DataAccess.DeleteByIdentity(this);
        }
    }
}
